// part1:C11:ex11.7.cpp
// add child to family
#include <iostream>
#include <map>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;

void add_family(map<string, vector<string>>& families, const string& family)
{
    if (families.find(family) == families.end()) 
    {
        families[family] = vector<string>();
    }
}

void add_child(map<string, vector<string>>& families, const string& family,
    const string& child)
{
    families[family].push_back(child);
}

int main(int argc, char *argv[])
{
    map<string, vector<string>> families;
    add_family(families, "Zhang");
    add_child(families, "Zhang", "qiang");
    add_child(families, "Zhang", "mi");
    add_child(families, "Zhang", "xiu");
    add_family(families, "Wang");

    for (auto f : families)
    {
        cout << f.first << " children : ";
        for (auto c : f.second)
        {
            cout << c << " " << endl;
        }
        cout << endl;
    }
 
    return 0;
}